import txios from '../index'
import { IAccount, ILoginRes } from './type'
import type { IDataType } from '../types'
enum LoginAPI {
  AccountLogin = '/login',
  LoginUserInfo = '/users/',
  userMenus = '/role/'
}

export function accountLoginRequest(account: IAccount) {
  return txios.post<IDataType<ILoginRes>>({
    url: LoginAPI.AccountLogin,
    data: account,
    interceptorHooks: {
      requestInterceptor: (config: any) => {
        console.log(import.meta.env.PROD, 99999)
        return config
      },
      responseInterceptor: (res: any) => {
        console.log('单独请求响应的config')
        return res
      }
    }
  })
}

export function requestUserInfoById(id: number) {
  return txios.get<IDataType>({
    url: LoginAPI.LoginUserInfo + id,
    showLoading: false
  })
}

export function requestUserMenusByRoleId(id: number) {
  return txios.get<IDataType>({
    url: LoginAPI.userMenus + id + '/menu',
    showLoading: false
  })
}
